package com.ruoyi.back.service.impl

import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.back.domain.WxPaySetting
import com.ruoyi.back.mapper.WxPaySettingMapper
import com.ruoyi.back.service.WxPaySettingService
import org.springframework.stereotype.Service

@Service
class WxPaySettingServiceImpl : ServiceImpl<WxPaySettingMapper, WxPaySetting>(), WxPaySettingService {

    override fun saveWxPaySetting(wxPaySetting: WxPaySetting): Data<Boolean> =
        wxPaySetting.id?.run {
            Ok("更新成功", updateById(wxPaySetting))
        } ?: Ok("保存成功", save(wxPaySetting))

    override fun getWxPaySetting(): Data<WxPaySetting> =
        Ok("获取成功", getOne(KtQueryWrapper(WxPaySetting::class.java)))
}